package com.example.jddjxx.constant;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * <p>Msg</p>
 * description
 *
 * @author 邓峰峰
 * @date 2020/5/11 17:38
 */
@Getter
public enum Msg {


    newAfterSaleBill("创建售后单消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3,Scheme.price,Scheme.afs);
        }
    },

    afterSaleBillStatus("售后单状态消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3,Scheme.price,Scheme.afs);
        }
    },

    newApplyAfterSaleBill("创建售后单申请消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3,Scheme.price,Scheme.afs);
        }
    },

    updateApplyAfterSaleBill("修改售后单申请消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3,Scheme.price,Scheme.afs);
        }
    },

    afterSaleJdBillFinish("售后单最终完成消息（物竞天择）"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.afs);
        }
    },


    newSku("新增商品消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },

    updateSku("修改商品消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },

    stockIsHave("门店商品库存上下架状态消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods,Scheme.price);
        }
    },

    brandCreated("新增商品品牌消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },

    brandModify("修改商品品牌消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },

    categoryInfoOper("新增或修改商品类目消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },

    uploadSkuPictureFail("商品图片上传失败消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.goods);
        }
    },


    orderAccounting("订单应结消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3,Scheme.money);
        }
    },

    financeAdjustment("财务调整单消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.money);
        }
    },



    pickFinishOrder("拣货完成消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    deliveryOrder("订单开始配送消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    finishOrder("订单妥投消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    lockOrder("订单锁定消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    userCancelOrder("用户取消消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    newOrder("创建新订单消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    applyCancelOrder("用户申请取消消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    endOrderFinance("订单金额拆分完成消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    orderAdjust("订单调整消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    pushDeliveryStatus("订单运单状态消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    orderInfoChange("订单信息变更消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    orderWaitOutStore("订单等待出库消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    orderAddTips("订单商家小费消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    unlockOrder("订单解锁消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    deliveryCarrierModify("订单转自送消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },


    venderAuditApplyCancelOrder("商家审核用户取消申请消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },




    internetHospitalAudit("互联网医院审核处方单消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    newOrderForPrescription("创建新处方药订单消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },

    orderInvoice("订单发票消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.order3);
        }
    },







    wmsMerchantStockChang("哥伦布WMS仓储库存变更消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.price);
        }
    },



    singlePromoteCreate("单品级促销创建活动消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.sale);
        }
    },

    /**
     * 订单级促销活动状态消息
     * 由于京东到家开放平台的bug,这里必须写"订单级促销创建活动消息"才能正常工作
     */
    orderPromoteCreate("订单级促销创建活动消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.sale);
        }
    },

    createOrderPromote("订单级促销创建活动消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.sale);
        }
    },

    merchantApproval("到家产生优惠券id时通知商家审批消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.sale);
        }
    },



    orderCommentPush("新增或修改门店订单评价消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.store);
        }
    },

    orgCommentAudit("商家评价审核完成消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.store);
        }
    },

    storeCrud("新增或修改门店消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.store);
        }
    },

    queryMerchantMemberInfo("查询商家会员信息接口"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.store,Scheme.vip);
        }
    },


    memberCreateCard("商家会员买卡成功消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.vip);
        }
    },

    memberRenewCard("商家会员续费成功消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.vip);
        }
    },


    orderPaymentSuccess("超级会员码订单支付成功消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.vip);
        }
    },

    offlineVipPointsChange("线下积分会员消息"){
        @Override
        public List<Scheme> schemes() {
            return Arrays.asList(Scheme.vip);
        }
    },


    ;

    private final String title;

    /**
     * 消息对应的方案集合
     * @return
     */
    public abstract List<Scheme> schemes();

//    private final Scheme scheme;

    Msg(String title) {
        this.title = title;
    }

//    Msg(String title, Scheme scheme) {
//        this.title = title;
//        this.scheme = scheme;
//    }

    public static final String SEPARATOR = ";&";
    public static Map<String,Msg> map(){
        return Arrays.stream(Msg.values()).collect(Collectors.toMap(
                msg -> msg.name()+ SEPARATOR +msg.title,
                Function.identity(),
                (a,b)->a
        ));
    }

    public static Msg valueBy(String title){
        for (Msg msg : Msg.values()) {
            if (msg.getTitle().equals(title)){
                return msg;
            }
        }
        return null;
    }
}
